package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

//程序启动后用户在控制台输入的每一行字母串都写入到文件note.txt
//当用户单独输入exit时程序退出 写入文件的内容不用考虑换行
public class TestNote {
    public static void main(String[] args) throws IOException, InterruptedException {
/*
用scanner
while +break
fileO +字符串写入
 */
        String word;
        Scanner sc=new Scanner(System.in);
        FileOutputStream file=new FileOutputStream("note.txt",false);
        while (true){
word=sc.nextLine();
if (word.equals("exit")){
    System.out.println("退出");
    break;
        }else {
    file.write(word.getBytes(StandardCharsets.UTF_8));
}
            System.out.println("结束了");
file.close();
    }
}
}
